Abstract interface for matrix classes. More...
#include <matrix_interface.hpp>
Public Types | |
typedef T | TheType |
typedef I | IdxType |
Public Member Functions | |
BaseMatrixInterface (void) | |
Default constructor. | |
~BaseMatrixInterface (void) | |
Destructor. | |
void | localRowRange (IdxType &lo, IdxType &hi) const |
Get the global index range of the locally owned rows. | |
IdxType | rows (void) const |
Get the total number of rows in this matrix. | |
IdxType | localRows (void) const |
Get the number of local rows in this matirx. | |
IdxType | cols (void) const |
Get the number of columns in this matrix. | |
IdxType | localCols (void) const |
Get the number of local columns in this matirx. | |
void | setElement (const IdxType &i, const IdxType &j, const TheType &x) |
Set an individual element. | |
void | setElements (const IdxType &n, const IdxType *i, const IdxType *j, const TheType *x) |
Set an several elements. | |
void | addElement (const IdxType &i, const IdxType &j, const TheType &x) |
Add to an individual element. | |
void | addElements (const IdxType &n, const IdxType *i, const IdxType *j, const TheType *x) |
Add to an several elements. | |
void | getElement (const IdxType &i, const IdxType &j, TheType &x) const |
Get an individual element. | |
void | getElements (const IdxType &n, const IdxType *i, const IdxType *j, TheType *x) const |
Get an several elements. | |
void | getRow (const IdxType &row, TheType *x) const |
Get a row and put it in a local array. | |
void | getRowBlock (const IdxType &nrow, const IdxType *rows, TheType *x) const |
Get some rows and put them in a local array. | |
void | identity (void) |
Make this matrix the identity matrix. | |
void | addDiagonal (const TheType &x) |
Shift the diagonal of this matrix by the specified value. | |
void | scale (const TheType &x) |
Scale this entire MatrixT by the given value. | |
void | real (void) |
Replace all elements with their real parts. | |
void | imaginary (void) |
Replace all elements with their imaginary parts. | |
void | conjugate (void) |
Replace all elements with their complex gradient. | |
double | norm2 (void) const |
Compute the matrix L2 norm. | |
void | zero (void) |
Zero all entries in the matrix. | |
void | ready (void) |
Indicate the matrix is ready to use. | |
void | print (const char *filename=NULL) const |
Print to named file or standard output. | |
void | save (const char *filename) const |
Save, in MatLAB format, to named file (collective). | |
void | loadBinary (const char *filename) |
Load from a named file of whatever binary format the math library uses. | |
void | saveBinary (const char *filename) const |
Save to named file in whatever binary format the math library uses. |
Abstract interface for matrix classes.
typedef I gridpack::math::BaseMatrixInterface< T, I >::IdxType |
The size/index type used.
Reimplemented in gridpack::math::MatrixT< T, I >.
typedef T gridpack::math::BaseMatrixInterface< T, I >::TheType |
The numeric type used.
Reimplemented in gridpack::math::MatrixT< T, I >.
gridpack::math::BaseMatrixInterface< T, I >::BaseMatrixInterface | ( | void | ) |
Default constructor.
gridpack::math::BaseMatrixInterface< T, I >::~BaseMatrixInterface | ( | void | ) |
Destructor.
void gridpack::math::BaseMatrixInterface< T, I >::addDiagonal | ( | const TheType & | x | ) |
Shift the diagonal of this matrix by the specified value.
Collective
.
x |
void gridpack::math::BaseMatrixInterface< T, I >::addElement | ( | const IdxType & | i, | |
const IdxType & | j, | |||
const TheType & | x | |||
) |
Add to an individual element.
Local.
i | global, 0-based row index | |
j | global, 0-based column index | |
x | value to add to matrix element |
void gridpack::math::BaseMatrixInterface< T, I >::addElements | ( | const IdxType & | n, | |
const IdxType * | i, | |||
const IdxType * | j, | |||
const TheType * | x | |||
) |
Add to an several elements.
Local.
n | number of elements to update | |
i | array of n global, 0-based row indexes | |
j | array of n global, 0-based column indexes | |
x | array of n values to add to existing matrix elements |
IdxType gridpack::math::BaseMatrixInterface< T, I >::cols | ( | void | ) | const |
Get the number of columns in this matrix.
Local.
void gridpack::math::BaseMatrixInterface< T, I >::conjugate | ( | void | ) |
Replace all elements with their complex gradient.
void gridpack::math::BaseMatrixInterface< T, I >::getElement | ( | const IdxType & | i, | |
const IdxType & | j, | |||
TheType & | x | |||
) | const |
Get an individual element.
Local
.
Only local elements may be retrieved using this method.
i | global, 0-based row index | |
j | global, 0-based column index | |
x | variable in which to place retrieved value |
void gridpack::math::BaseMatrixInterface< T, I >::getElements | ( | const IdxType & | n, | |
const IdxType * | i, | |||
const IdxType * | j, | |||
TheType * | x | |||
) | const |
Get an several elements.
Local
.
Only local elements may be retrieved using this method.
n | number of elements to retrieve | |
i | array of n global, 0-based row indexes | |
j | array of n global, 0-based column indexes | |
x | array of n values in which retrieved values are to be placed |
void gridpack::math::BaseMatrixInterface< T, I >::getRow | ( | const IdxType & | row, | |
TheType * | x | |||
) | const |
Get a row and put it in a local array.
void gridpack::math::BaseMatrixInterface< T, I >::getRowBlock | ( | const IdxType & | nrow, | |
const IdxType * | rows, | |||
TheType * | x | |||
) | const |
Get some rows and put them in a local array.
(Collective)
This gets the elements in the specified rows and puts them in the specified array. It is assumed that the array is appropriately sized (nrow * columns). While this is collective, each processor may get a different set of rows. Row/column ownership should not matter.
nrow | ||
rows | ||
x |
void gridpack::math::BaseMatrixInterface< T, I >::identity | ( | void | ) |
Make this matrix the identity matrix.
Collective
void gridpack::math::BaseMatrixInterface< T, I >::imaginary | ( | void | ) |
Replace all elements with their imaginary parts.
void gridpack::math::BaseMatrixInterface< T, I >::loadBinary | ( | const char * | filename | ) |
IdxType gridpack::math::BaseMatrixInterface< T, I >::localCols | ( | void | ) | const |
Get the number of local columns in this matirx.
void gridpack::math::BaseMatrixInterface< T, I >::localRowRange | ( | IdxType & | lo, | |
IdxType & | hi | |||
) | const |
Get the global index range of the locally owned rows.
Local.
lo | first (0-based) index of locally owned rows | |
hi | one more than the last (0-based) index of locally owned rows |
IdxType gridpack::math::BaseMatrixInterface< T, I >::localRows | ( | void | ) | const |
Get the number of local rows in this matirx.
Local.
double gridpack::math::BaseMatrixInterface< T, I >::norm2 | ( | void | ) | const |
Compute the matrix L2 norm.
Collective.
The vector L2, or Euclidian, norm is computed as
void gridpack::math::BaseMatrixInterface< T, I >::print | ( | const char * | filename = NULL |
) | const |
Print to named file or standard output.
Collective.
The format is dependent on the specific vector implementation.
filename | optional file |
void gridpack::math::BaseMatrixInterface< T, I >::ready | ( | void | ) |
Indicate the matrix is ready to use.
Collective.
This is used to indicate that the matrix is ready to use. This must be called after all setElement() or addElement() calls and before the vector is used for any operation.
void gridpack::math::BaseMatrixInterface< T, I >::real | ( | void | ) |
Replace all elements with their real parts.
IdxType gridpack::math::BaseMatrixInterface< T, I >::rows | ( | void | ) | const |
Get the total number of rows in this matrix.
Local.
void gridpack::math::BaseMatrixInterface< T, I >::save | ( | const char * | filename | ) | const |
Save, in MatLAB format, to named file (collective).
Collective.
filename |
void gridpack::math::BaseMatrixInterface< T, I >::saveBinary | ( | const char * | filename | ) | const |
void gridpack::math::BaseMatrixInterface< T, I >::scale | ( | const TheType & | x | ) |
Scale this entire MatrixT by the given value.
Collective.
x | factor by which all elements in the matrix are multiplied |
void gridpack::math::BaseMatrixInterface< T, I >::setElement | ( | const IdxType & | i, | |
const IdxType & | j, | |||
const TheType & | x | |||
) |
Set an individual element.
Local.
This overwrites the value at the specified i
row and j
column. ready() must be called after all setElement() calls and before using the matrix.
i | global (0-based) row index | |
j | global (0-based) column index | |
x | value to place in matrix |
void gridpack::math::BaseMatrixInterface< T, I >::setElements | ( | const IdxType & | n, | |
const IdxType * | i, | |||
const IdxType * | j, | |||
const TheType * | x | |||
) |
Set an several elements.
Local.
This overwrites values at several locations in the matrix. ready() must be called after all setElements() calls and before using the matrix.
n | number of values to place in | |
i | array of n global, 0-based row indexes | |
j | array of n global, 0-based column indexes | |
x | array of n values to replace existing matrix elements |
void gridpack::math::BaseMatrixInterface< T, I >::zero | ( | void | ) |
Zero all entries in the matrix.
Collective.